<template>
    <div>
        <!-- 顶部滑动条区域 -->
        <div id="slider" class="mui-slider">
            <div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
                <div class="mui-scroll">
                    <a :class="['mui-control-item',item.id == 1 ? 'mui-active':'']" v-for="item in type" :key="item.id">
                        {{ item.type_name }}
                    </a>
                </div>
            </div>
		</div>

        <!-- 图片列表区域 -->
        <ul class="photo-list">
            <router-link v-for="item in list" :key="item.id" :to="'/home/photoinfo/'+item.id" tag="li">
                <img v-lazy="item.img_url">
                <div class="info">
                    <h1 class="info-title">{{ item.title }}</h1>
                    <div class="info-body">{{ item.zhaiyao }}</div>
                </div>
            </router-link>
        </ul>
    </div>
</template>


<script>
// 1.导入mui 的js 文件
import mui from '../../lib/mui/js/mui.min.js'


export default {
    data() {
        return {
            type:[ // 分类数组
                {id:1,type_name:'推荐'},
                {id:2,type_name:'家居生活'},
                {id:3,type_name:'摄影设计'},
                {id:4,type_name:'明星美女'},
                {id:5,type_name:'美女写真'},
                {id:6,type_name:'未知图片'}
            ],
            list:[//图片列表数组
                {id:1,title:'测试0',img_url:'src/images/img01.jpg',zhaiyao:'123'},
                {id:2,title:'测试1',img_url:'src/images/img02.jpg',zhaiyao:'1234'},
                {id:3,title:'测试2',img_url:'src/images/img03.jpg',zhaiyao:'1235'},
                {id:4,title:'测试3',img_url:'src/images/img04.jpg',zhaiyao:'1236'}
            ]            
        }
    },
    mounted() {// 当组件的DOM结构被渲染好并放到页面中后 执行这个 钩子函数
        // 2 初始化滑动控件
        mui('.mui-scroll-wrapper').scroll({
            deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
        });
    },
    methods: {
        
    },
}
</script>

<style lang="scss" scoped>
*{
    touch-action: pan-y;
}
.photo-list{
    list-style: none;
    padding: 0;
    margin: 10px;
    padding-bottom: 0;
    li{
        background-color: #ccc;
        text-align: center;
        margin-bottom: 10px;
        box-shadow: 0 0 12px #999;
        position: relative;
        
        img{
            width: 100%;
            vertical-align: middle;
        }
        img[lazy=loading] {
            width: 40px;
            height: 300px;
            margin: auto;
        }
    }
    .info{
        color: white;
        text-align: center;
        position: absolute;
        bottom: 0;
        // background-color: rgba(0,0,0,0.4);
        max-height: 84px;
        .info-title{
            font-size: 14px;
        }
        .info-body{
            font-size: 13px;
        }
    }

}


</style>